package EP1.main;

import java.math.BigInteger;

import EP1.algoritmos.Algoritmo3;
import EP1.algoritmos.algoritmo1.Algoritmo1;
import EP1.algoritmos.algoritmo2.Algoritmo2;

public class Ep1 {

    public static void main(String[] args) {
	if (args.length != 2)
	    throw new RuntimeException("Invalid args");
	int algorithm = Integer.parseInt(args[0]);
	int n = Integer.parseInt(args[1]);
	int cores = 2;
	long t0, t1;

	for (int i = 0; i < 1; i++) {
	    switch (algorithm) {
	    case 1:
		t0 = System.currentTimeMillis();
		cores = CoreNumberFinder.findCoreNumber();
		System.out.println("Cores = " + cores);
		float result = Algoritmo1.calculaSoma(cores, n);
		t1 = System.currentTimeMillis();
		System.out.println("Time = " + (t1 - t0) + "ms");
		System.out.println("S(1) = " + result);
		break;
	    case 2:
		t0 = System.currentTimeMillis();
		cores = CoreNumberFinder.findCoreNumber();
		System.out.println("Cores = " + cores);
		BigInteger result2 = Algoritmo2.calculaSoma(cores, n);
		t1 = System.currentTimeMillis();
		System.out.println("Time = " + (t1 - t0) + "ms");
		System.out.println("S(2) = " + result2.toString());
		break;
	    case 3:
		t0 = System.currentTimeMillis();
		cores = CoreNumberFinder.findCoreNumber();
		System.out.println("Cores = " + cores);
		double result3 = Algoritmo3.calculaSoma(cores, n);
		t1 = System.currentTimeMillis();
		System.out.println("Time = " + (t1 - t0) + "ms");
		System.out.println("S(3) = " + result3);
		break;		
	    default:
		throw new RuntimeException("Invalid Algorithm");
	    }
	}

    }

}
